﻿using System.Drawing;
using DevExpress.Utils;
using DevExpress.XtraBars.Alerter;
using DevExpress.XtraEditors;

namespace Com.OpenCode.Framework.Log
{
    public class OpenCodeAlertControlHelper
    {
        private static XtraForm _Form = new XtraForm();

        public static void ShowInfo(string caption, string context)
        {
            AlertControl _OpenCodeAlertControl = CreateAlertControl();
            _OpenCodeAlertControl.AppearanceText.ForeColor = Color.Blue;
            _OpenCodeAlertControl.Show(_Form, caption, context);
        }

        public static void ShowWaring(string caption, string context)
        {
            AlertControl _OpenCodeAlertControl = CreateAlertControl();
            _OpenCodeAlertControl.AppearanceText.ForeColor = Color.Green;
            _OpenCodeAlertControl.Show(_Form, caption, context);
        }

        public static void ShowError(string caption, string context)
        {
            AlertControl _OpenCodeAlertControl = CreateAlertControl();
            _OpenCodeAlertControl.AppearanceText.ForeColor = Color.Red;
            _OpenCodeAlertControl.Show(_Form, caption, context);
        }

        private static AlertControl CreateAlertControl()
        {
            AlertControl _OpenCodeAlertControl = new AlertControl();
            _OpenCodeAlertControl.FormMaxCount = 5;
            _OpenCodeAlertControl.AutoFormDelay = 5000;
            _OpenCodeAlertControl.ShowPinButton = false;
            _OpenCodeAlertControl.AllowHotTrack = false;
            _OpenCodeAlertControl.AppearanceText.TextOptions.Trimming = Trimming.None;
            _OpenCodeAlertControl.FormShowingEffect = AlertFormShowingEffect.SlideVertical;
            return _OpenCodeAlertControl;
        }
    }
}